package pkg

import (
	"encoding/json"
	"fmt"
	MQ "order_srv/basic/init"
	"order_srv/handler/models"
)

func PublishMQ(seckillOrder *models.Orders) error {
	marshal, err := json.Marshal(seckillOrder)
	if err != nil {
		return err
	}

	RabbitMQ := MQ.NewRabbitMQSimple("2301a")
	Simple, err := RabbitMQ.PublishSimple(marshal)
	if err != nil {
		return err
	}

	if !Simple {
		// 添加错误处理逻辑
		return fmt.Errorf("发布消息失败")
	}
	return nil
}
